package com.gc.jbnfgen.gen;

/**
 *
 * @author dmitry.mamonov
 */
class Concat {
    private StringBuilder text = new StringBuilder();
    public Concat enter(Object... objList){
        glue(objList);
        text.append("\n");
        return this;
    }

    public Concat spaces(Object... objList){
        boolean first = true;
        for(Object obj:objList){
            if (first){
                first=false;
            } else {
                text.append(" ");
            }
            text.append(obj);
        }
        return this;
    }

    public Concat glue(Object... objList){
        for(Object obj:objList){
            text.append(obj);
        }
        return this;
    }

    public Concat nested(Concat concat){
        for(String line:concat.toString().split("\n")){
            glue("    ",line).enter();
        }
        return this;
    }

    @Override
    public String toString() {
        return text.toString();
    }
}
